<template>
  <div class="avue-logo">
    <transition name="fade">
      <span v-if="keyCollapse"
            key="0"
            class="avue-logo_subtitle">
        {{ website.logo }}
        <!-- FC -->
      </span>
    </transition>
    <transition-group name="fade">
      <template v-if="!keyCollapse">
        <!-- <span key="1"
              class="avue-logo_title">{{ orgInfo?orgInfo.orgName:website.indexTitle }} </span> -->
        <!-- <span key="1"
              class="avue-logo_title">FutureCell赋智赛尔</span> -->
        <img v-if="orgInfo"
             id="head-image"
             key="1"
             class="avue-logo_title" />
        <span v-else>{{website.indexTitle}}</span>
      </template>
    </transition-group>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { handleImg } from '../../util/util'
export default {
  name: 'Logo',
  data () {
    return {}
  },
  mounted () {
    this.initImage()
  },
  watch: {
    keyCollapse () {
      if (!this.keyCollapse) this.initImage()
    }
  },
  computed: {
    ...mapGetters(['website', 'keyCollapse', 'orgInfo'])
  },
  methods: {
    initImage () {
      handleImg(this.orgInfo.logo, 'head-image')
    }
  }
}
</script>

<style lang="scss">
.fade-leave-active {
  transition: opacity 0.2s;
}
.fade-enter-active {
  transition: opacity 2.5s;
}
.fade-enter,
.fade-leave-to {
  opacity: 0;
}
#head-image {
  width: 240px;
  height: 65px;
  object-fit: cover;
}
.avue-logo {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 65px;
  line-height: 64px;
  background-color: #20222a;
  font-size: 20px;
  overflow: hidden;
  box-sizing: border-box;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.15);
  color: rgba(255, 255, 255, 0.8);
  z-index: 1026;
  &_title {
    display: block;
    text-align: center;
    font-weight: 300;
    font-size: 16px;
  }
  &_subtitle {
    display: block;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    color: #fff;
  }
}
</style>
